﻿var map;
var _mNumber = 0;
var _prvMarker;
var _vtorMarker;
var _postBackString;
var _startStation
var _endStation
function crtaj() {
    var options = {
        zoom: 13,
        center: new google.maps.LatLng(41.99997, 21.3983),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        navigationControl: true,
        streetViewControl: false,
        scaleControl: true
    };
    var _mapDiv = document.getElementById("map");
    map = new google.maps.Map(_mapDiv, options);

    google.maps.event.addListener(map, 'click', function (e) {
        _mNumber++;
        if (_mNumber == 1) {
            _prvMarker = new google.maps.Marker({ position: e.latLng });
            var _prvImage = new google.maps.MarkerImage('../images/markerA.png', new google.maps.Size(20, 34), new google.maps.Point(0, 0), new google.maps.Point(15, 15));
            _prvMarker.setMap(map);
            _prvMarker.setIcon(_prvImage);
            $("input[id$='markerA']").filter(":hidden").val(_prvMarker.getPosition().lat().toString() + "!" + _prvMarker.getPosition().lng().toString());
        }
        else if (_mNumber == 2) {
            _vtorMarker = new google.maps.Marker({ position: e.latLng });
            var _vtorImage = new google.maps.MarkerImage('../images/markerB.png', new google.maps.Size(20, 34), new google.maps.Point(0, 0), new google.maps.Point(15, 15));
            _vtorMarker.setMap(map);
            _vtorMarker.setIcon(_vtorImage);
            $("input[id$='markerB']").filter(":hidden").val(_vtorMarker.getPosition().lat().toString() + "!" + _vtorMarker.getPosition().lng().toString()) ;
        }
    });
}
function clearAll() {
    _prvMarker.setMap(null);
    _vtorMarker.setMap(null);
    _mNumber = 0;
}
function ShowMarkers(startLat,startLon,endLat,endLon) {
    _startStation = new google.maps.Marker({ position: new google.maps.LatLng(startLat,startLon) });
    var _Image = new google.maps.MarkerImage('../images/busstation.png',new google.maps.Size(24, 24),new google.maps.Point(0,0),new google.maps.Point(15, 15));
    _startStation.setMap(map);
    _startStation.setIcon(_Image);

    _endStation = new google.maps.Marker({ position: new google.maps.LatLng(endLat, endLon) });
    _endStation.setMap(map);
    _endStation.setIcon(_Image);

    _prvMarker.setMap(map);
    _vtorMarker.setMap(map);
}